import { _decorator, director, Scene } from 'cc';

export class MyEvent {
    static CAMERA_ROTATE = "CAMERA_ROTATE";
    static CAMERA_ZOOM = "CAMERA_ZOOM";
    static MOVE_STOP = "MOVEMENT_STOP";
    static JUMP = "JUMP";
    static SKILL = "SKILL";
    static SKILL_COOLDOWN = "SKILL_COOLDOWN";

    static HIDE_TIP = "HIDE_TIP";

    static REFRESH_HPBAR = "REFRESH_HPBAR";
    static REFRESH_CHARACTOR = "REFRESH_CHARACTOR";
    static REFRESH_MONEY = "REFRESH_MONEY";
    static REFRESH_SHOPITEMS = "REFRESH_SHOPITEMS";

    static SET_ITEM = "SET_ITEM";

    static MOVE = "MOVE";
    static MOVEMENT = "MOVEMENT";
    static MOVEMENT_STOP = "MOVEMENT_STOP";
    static Fire = "Fire";
    static SET_ATTACK_DIR = "SET_ATTACK_DIR";
    static WEAPON_UNCHECKED = "WEAPON_UNCHECKED";
    static MAGAZINE_UNCHECKED = "MAGAZINE_UNCHECKED";
    static BULLET_UNCHECKED = "BULLET_UNCHECKED";
    static SHOPITEM = "SHOPITEM";
    static ATTACKSTART = "ATTACKSTART";
    static ATTACKEND = "ATTACKEND";
    static RELOAD = "RELOAD";
    static UPDATESLD = "UPDATESLD";
    static FL = "FL";
}

export class EventManager {
    public static get Scene(): Scene {
        return director.getScene();
    }

    public static on(type: string, callback: Function, target?: any) {
        director.getScene().on(type, callback, target);
    }

    public static off(type: string, callback?: Function, target?: any) {
        director.getScene()?.off(type, callback, target);
    }
}